package com.dxq.test.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.R;
import com.dxq.test.db.Event;
import com.dxq.test.db.Label;

import java.util.List;

/**
 * Author: zsh
 * Date: 2023/11/08
 * Describe: 牲畜列表adapter
 */
public class LivestockAdapter extends BaseQuickAdapter<Label, BaseViewHolder> {

    public LivestockAdapter(int layoutResId) {
        this(layoutResId, null);
    }

    public LivestockAdapter(int layoutResId, @Nullable List<Label> data) {
        super(layoutResId, data);
        addChildClickViewIds(R.id.tvAdd);
    }

    @Override
    protected void convert(BaseViewHolder holder, Label item) {
        //holder.setText(R.id.tvSize, String.valueOf(1 + holder.getLayoutPosition()));
        holder.setText(R.id.tvID, item.getID());
        holder.setText(R.id.tvName, item.getName());
        holder.setText(R.id.tvBreedingStatus, item.getBreedingStatus());
        String sex = item.getSex();
        holder.setText(R.id.tvSex, sex);
//        if (sex.equals("公")) {
//            holder.setBackgroundResource(R.id.llMain, R.drawable.box_bg);
//        } else {
//            holder.setBackgroundResource(R.id.llMain, R.drawable.box2_bg);
//        }
//        Event eventID = item.getEvent_id();
//        if (eventID == null) {
//            holder.setText(R.id.tvEvent, "未设置事件");
//        } else {
//            holder.setText(R.id.tvEvent, eventID.getName());
//        }
    }
}
